import { request } from '../../../services/request';
import { SrnQueryParams, SrnResponse } from './types';

export const querySrn = async (params: SrnQueryParams): Promise<SrnResponse> => {
    console.log('请求参数:', params);

    try {
        const response = await request('/app/wms/srn/querySrn', {
            method: 'POST',
            body: JSON.stringify(params),
        });

        console.log('接口返回:', response);
        return response;
    } catch (error) {
        console.error('查询 ASN 失败:', error);
        throw error;
    }
};

export const confirmSrn = async (bodyIds: string[]): Promise<any> => {
    console.log('确认出货请求参数:', bodyIds);

    try {
        const params = bodyIds.map(id => ({ srn_body_id: id }));
        const response = await request('/app/wms/srn/confirmSrn', {
            method: 'POST',
            body: JSON.stringify(params),
        });

        console.log('确认出货接口返回:', response);
        return response;
    } catch (error) {
        console.error('确认出货失败:', error);
        throw error;
    }
};
